home *** CD-ROM | disk | FTP | other *** search
/ Tech Arsenal 1 / Tech Arsenal (Arsenal Computer).ISO / tek-02 / asg53.zip / BLUEBAG.DOC < prev    next >
Text File  |  1990-01-31  |  10KB  |  250 lines

  1. Documentation for the BlueBag Unit (Ver 5.3) found in ASG53.ARC
  2.  
  3. Routines are available for modifying the cursor, CRT tricks, dates, string
  4. processing, testing printer status, and multiple overlapping windows. This
  5. updated unit was partly rewritten in Assembler for reduced size and faster
  6. performance. Desirable in itself this unit is essential for the AtSayGet
  7. line editing procedures available in the ASG53.ARC file. The interface is
  8. noted below (routines grouped by function) followed by an alphabetical
  9. listing and explanation of each routine.
  10.  
  11. {$R-,V-,B-}
  12. UNIT BlueBag;
  13.  
  14. INTERFACE
  15. USES
  16.  Crt,
  17.  DOS;
  18.  
  19. TYPE
  20.  Xrange=1..80;
  21.  Yrange=1..25;
  22.  LptRange=0..2;
  23.  Date = LONGINT;
  24.  DateString = STRING[8];
  25.  DelimitedDate = STRING[10];
  26.  DofW = 1..7;
  27.  MofY = 1..12;
  28. CONST
  29.  IsColor : BOOLEAN=True; {Display mode at startup}
  30.  BadDate = $7FFFFFFF;
  31.  
  32. VAR
  33.  StartScan,
  34.  StopScan  : BYTE;  {Cursor shape at startup}
  35.  
  36.  OrgAttr,
  37.  SayAttr,
  38.  GetAttr,
  39.  EndAttr   : BYTE;  {AtSayGet attribute bytes}
  40.  
  41. (* 10 CRT procedures *)
  42. PROCEDURE CursorSave;                          {obj code}
  43. PROCEDURE CursorOn;                            {obj code}
  44. PROCEDURE CursorOff;                           {obj code}
  45. PROCEDURE RestoreCursor;                       {obj code}
  46. PROCEDURE SetCursor(ScanStart,ScanStop:BYTE);  {obj code}
  47. PROCEDURE Center(Row:YRange; Mid:STRING);
  48. PROCEDURE CLEAR(X1,Y1,X2,Y2:INTEGER);
  49. PROCEDURE DrawBox(X1,Y1,X2,Y2,LineStyle:BYTE);
  50. PROCEDURE RestoreVideo;
  51. PROCEDURE ReverseVideo;
  52.  
  53. (* 12 DATE functions *)
  54. FUNCTION  DateStringToDate(DS:DateString):Date;
  55. FUNCTION  DateToDateString(DT:Date):DateString;
  56. FUNCTION  DayOfWeek(DT:Date):DofW;
  57. FUNCTION  DaysBetween(Early,Late:Date):LongInt;
  58. FUNCTION  DelimitDateString(DS:DateString):DelimitedDate;
  59. PROCEDURE IncDate(VAR DT:Date; Delta:LongInt);
  60. FUNCTION  MonthOfYear(DT:Date):MofY;
  61. FUNCTION  NameOfDay(DayNdx:DofW):STRING;
  62. FUNCTION  NameOfMonth(MoNdx:MofY):STRING;
  63. FUNCTION  StripDateString(DS:DelimitedDate):DateString;
  64. FUNCTION  SysDate:Date;
  65. FUNCTION  ValidDate(DS:DateString):BOOLEAN;
  66.  
  67. (* 11 STRING routines *)
  68. FUNCTION  IsBlank(TestStr:STRING):BOOLEAN;
  69. PROCEDURE NoBlanks(VAR HasBlanks:STRING);
  70. FUNCTION  Trim(LongLine:STRING):STRING;
  71. FUNCTION  UpperCase(S:STRING):STRING;          {obj code}
  72. FUNCTION  LowerCase(S:STRING):STRING;          {obj code}
  73. FUNCTION  LoCase(C:CHAR):CHAR;
  74. PROCEDURE WAIT;
  75. PROCEDURE RealToEnglish(Numeric:REAL; VAR Anglo:STRING);
  76. FUNCTION  NextWord(WordStr:STRING):STRING;
  77. PROCEDURE GetWordCount(WordStr:STRING; VAR WordCount:BYTE);
  78. FUNCTION  NthWord(WordStr : STRING;
  79.                   Nth     : BYTE ) : STRING;
  80.  
  81. (* 3 DEVICE functions *)
  82. FUNCTION  OnFile(FileName:STRING):BOOLEAN;
  83. FUNCTION  PrinterOnLine(LPTnum:LptRange):BOOLEAN;  {obj code}
  84. PROCEDURE PrtSc;
  85.  
  86. (* 2 WINDOW procedures *)
  87. PROCEDURE OpenWindow(TX:Xrange; TY:Yrange; BX:Xrange; BY:Yrange;
  88.                      FRG,BKG,Border : BYTE;
  89.                      Heading        : STRING);
  90. PROCEDURE CloseWindow;
  91.  
  92.  
  93. (* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *)
  94.  
  95.  Alphabetical listing of the 37 BLUEBAG routines and an explanation
  96.  of the purpose of each:
  97.  
  98.  
  99. CENTER writes on ROW the string passed to it. The string is centered on
  100. the screen or in the window.
  101.  
  102. CLEAR clears screen area defined by the coordinates using current text
  103. attribute. It is relative to any window that may be open.
  104. eg: Clear(5,5,10,10); {clears screen fron 5,5, to 10,10}
  105.  
  106. CLOSEWINDOW restores the image under the current window and frees the heap
  107. space that was used to store it.
  108. eg: CloseWindow; {closes the last window that was opened}
  109.  
  110. CURSOROFF turns off the cursor after saving the current cursor shape in
  111. StartScan and StopScan. A call to RESTORECURSOR will reset it to its shape
  112. before being turned off.
  113. eg: CursorOff; {hides the cursor}
  114.  
  115. CURSORON sets the cursor to the default setting for the monitor in use at
  116. startup.
  117. eg: CursorOn; {turns on the cursor}
  118.  
  119. CURSORSAVE saves the current cursor start and stop scan lines into the global
  120. variables StartScan and StopScan.
  121. eg: CursorSave; {saves the cursor shape}
  122.  
  123. DATESTRINGTODATE returns a (LongInt) Date from a (STRING[8]) DateString.
  124. eg: DateToDateString('07041776') returns 648869 in a 4 byte LongInt.
  125.  
  126. DATETODATESTRING returns a (STRING[8]) DateString from a (LongInt) Date.
  127. eg: DateToDateString(648869) returns '07041776'.
  128.  
  129. DAYSBETWEEN returns the number of days between the early and late dates.
  130. eg: DaysBetween(DateStringToDate('07041776'),DateToDateString('07041989'))
  131.     returns 77,796 (days).
  132.  
  133. DAYOFWEEK returns the ordinal day of week from a LongInt Date; 1=Saturday,
  134. 2=Sunday, 3=Monday, 4=Tuesday, 5=Wednesday, 6=Thursday, and 7=Friday.
  135. eg: CanadaDay:DateString='07011867';
  136.     DayOfWeek(DateStringToDate(CanadaDay)) returns 4 and
  137.     NameOfDay(4) returns 'Tuesday'.
  138.  
  139. DRAWBOW draws a box defined by the coordinates. LineStyles are 1 (single),
  140. 2 (double), (3, 4 are mixed ), or 32..254 (ASCII #32..#254).
  141. eg: DrawBox(5,5,10,10,219); {draws a box from 5,5, to 10,10 in CHR(219) = █ }
  142.  
  143. DELIMITDATESTRING returns a (STRING[10]) DelimitedDate from a (STRING[8])
  144. DateString. The resulting date string is delimited with slashes.
  145. eg: DelimitDateString('07011867') returns '07/01/1867'
  146.     DelimitDateString(DateToDateString(648869)) returns '07/04/1776'.
  147.  
  148. GETWORDCOUNT Returns the number of words in a string.
  149. eg: WordCount('Short and sweet') returns 3
  150.  
  151. INCDATE incriments a (LongInt) Date by delta days.
  152.  
  153. ISBLANK returns True if the string has is nul or all spaces, or False if the
  154. string has at least one character.
  155. eg: IsBlank('Something is here') is False;   IsBlank('     ') is True;
  156.  
  157. LOWERCASE returns a string in lowercase.
  158. eg: LowerCase('SMALL IS BEAUTIFUL') = 'small is beautiful'
  159.  
  160. MONTHOFYEAR returns the ordinal month of a (LongInt) Date.
  161. eg: MonthOfYear(648869) gives 7
  162.     NameOfMonth(7) returns 'July'
  163.  
  164. NAMEOFDAY returns the name of the day in English.
  165. For an example see: DAYOFWEEK.
  166.  
  167. NAMEOFMONTH returns the name of the month in English.
  168. For an example see MONTHOFYEAR.
  169.  
  170. NEXTWORD Returns the next word from a string.
  171.  
  172. NOBLANKS removes all blanks from a string.
  173. eg: SomeStr:STRING='JUNK 1      ';
  174.     SomeStr:=SomeStr+'.BAK';      (* Now SomeStr = 'JUNK 1      .BAK' *)
  175.     NoBlanks(SomeStr);            (* Now SomeStr = 'JUNK1.BAK' *)
  176.  
  177. NTHWORD Returns the Nth word in a string.
  178. eg: NthWord('This is short and Sweet',3) returns 'short'
  179.  
  180. ONFILE returns True if specified file exists. FileName defaults to the current
  181. directory or looks to the path specified.
  182. eg: OnFile('\UTIL\PCTOOLS.EXE') OR OnFile('PCTOOLS.EXE') results in True if
  183.     PCTOOLS.EXE is in the \util or current directory, otherwise returns False.
  184.  
  185. OPENWINDOW first stores the screen display within the coordinates specified
  186. and saves the image on the heap. It then draws a border using a border style
  187. and TextAttrs specified in the parameters. An optional title is permitted at
  188. the top of the window. A window is then opened within the border and the
  189. screen cleared. Up to 9 windows may be opened and they can overlap.
  190. eg: OpenWindow(5,5,50,12,White,Red,1,' HI MOM ') draws a single line frame
  191.     in white on a red background from 5,5 to 50,12 and opens a window within
  192.     the borders. The words ' HI MOM ' are centered at the top of the border.
  193.  
  194. PRINTERONLINE returns True if printer port status reports ready, else False.
  195. LPTnum RANGE IS 0..2 corresponding to the printer ports 1..3
  196. eg: PrinterOnLine(0) is False if you don't have a printer on port 1 or if you
  197.     do but the printer is off line. Tests out fine on Epson but other printers
  198.     may not respond as expected.
  199.  
  200. PROCEDURE PrtSc will print the screen to PRN as though the user had pushed
  201. the PrtSc key. It is desirable to determine that PrinterOnLine(0)=True before
  202. calling this procedure. Note that this procedure (very new to these units)
  203. has not been demonstrated in the DEMO.PAS program but try it out yourself.
  204.  
  205. REALTOENGLISH Takes a REAL value (Numeric) and outputs the English words
  206. that represent the Numeric in a STRING variable (Anglo). The maximum value
  207. that can be translated is $9,999,999.99
  208.  
  209. RESTORECURSOR restores the cursor to the shape it had before being turned off
  210. by the CursorOff procedure or modified by the SetCursor procedure.
  211. eg: RestoreCursor;
  212.  
  213. RESTOREVIDEO restores the video attribute to the condition before calling the
  214. ReverseVideo procedure (See below).
  215.  
  216. REVERSEVIDEO displays black charactors on light background on a mono screen;
  217. On color screens it displays a suitable dark colored charactor on light b/g.
  218.  
  219. SETCURSOR sets cursor start and stop scans for altering cursor shape.
  220. SetCursor(StartScan,StopScan) will always display a block cursor regardless of
  221. the monitor used.
  222. eg: SetCursor(5,6); { If used on a mono screen the cursor will be a dash "-" }
  223.  
  224. STRIPDATESTRING removes the delimitors (usually a slash) from a (STRING[10])
  225. delimitedDate and returns a (STRING[8]) DateString.
  226. eg: StripDateString('01/01/1989') returns '01011989'
  227.     StripDateString('01.01.1989') returns '01011989' also.
  228.  
  229. SYSDATE returns a (Longint) Date from the system clock; The result varies
  230. depending on the system date.
  231.  
  232. TRIM returns a string with any leading or trailing spaces removed.
  233. eg: Tight:=Trim(' and then she said   '); { Tight = 'and then she said' }
  234.  
  235. UPPERCASE returns a string in uppercase. Corrected version of assembly code
  236. listed on pgs 213-4 of the TP5 manual.
  237. eg: Uppidy:=UpperCase('and then she said'); { Uppidy='AND THEN SHE SAID' }
  238.  
  239. VALIDDATE returns True if the DateString is valid, else False.
  240. eg: ValidDate('02291988') returns True but
  241.     ValidDate('02291989') returns False (because 1989 is not a leapyear).
  242.  
  243. WAIT turns off cursor, prints the message 'Press any key to continue' at the
  244. current cursor location, waits for any key to be pressed, and then restores
  245. the cursor.
  246. eg: Wait;  { Displays: Press any key to continue }
  247.  
  248. (* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *)
  249.  
  250. {See Demo.pas for some examples of how to use the routines in this unit}